<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head>
	<base th:href="@{/}">
	<meta charset="utf-8">
	<title>修改</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="static/selectY/css/selectY.css">
	<style type="text/css">
		.layui-form-label {
		    white-space: nowrap;
		}
	</style>
</head>
<body class="layui-fluid">
	<div class="layui-row">
		<div class="layui-col-md6 layui-col-md-offset3">
			<form class="layui-form" action="">
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">用户编码</label>
						<div class="layui-input-block">
							<input type="text" id="userCode" th:value="${user.userCode}" placeholder="请输入用户编码" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">用户名称</label>
						<div class="layui-input-block">
							<input type="text" id="userName" th:value="${user.userName}" placeholder="请输入用户名称" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">电话</label>
						<div class="layui-input-block">
							<input type="text" id="userPhone" th:value="${user.userPhone}" placeholder="请输入电话" class="layui-input">
						</div>
					</div>
				</div>
				<!-- <div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">年龄</label>
						<div class="layui-input-block">
							<input type="text" id="userAge" th:value="${user.userAge}" placeholder="请输入年龄" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">性别</label>
						<div class="layui-input-block">
							<select id="userSex" lay-search th:field="${user.userSex}">
								<option value="">请搜索或选择角色</option>
								<option value="男">男</option>
								<option value="女">女</option>
							</select>
						</div>
					</div>
				</div> -->
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">地址</label>
						<div class="layui-input-block">
							<input type="text" id="userAddr" th:value="${user.userAddr}" placeholder="请输入地址" class="layui-input">
						</div>
					</div>
				</div>
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">邮箱</label>
						<div class="layui-input-block">
							<input type="text" id="userEmail" th:value="${user.userEmail}" placeholder="请输入邮箱" class="layui-input">
						</div>
					</div>
				</div>
				<!-- <div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">部门</label>
						<div class="layui-input-block">
							<input type="text" class="layui-input" style="display: none;" id="departmentId" th:value="${user.departmentId}"/>
							<input type="text" lay-filter="departmentName" class="layui-input" id="departmentName"/>
						</div>
					</div>
				</div> -->
				<div class="layui-form-item" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">角色</label>
						<div class="layui-input-block">
							<input type="text" style="display: none;" class="layui-input" id="roleId" th:value="${user.roleId}"/>
							<input type="text" lay-filter="roleName" class="layui-input" id="roleName"/>
						</div>
					</div>
				</div>
				<div class="layui-form-item layui-hide" id="vendorDiv" style="margin-top: 20px;">
					<div class="layui-inline">
						<label class="layui-form-label">供应商</label>
						<div class="layui-input-inline">
							<select id="erpSupplier" lay-search th:field="${user.erpSupplier}">
								<option value="">请搜索或选择供应商</option>
								<option th:each="e:${vendorList}" th:value="${e.cVenCode}" th:text="${e.cVenName}"></option>
							</select>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript" src="static/plugin/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="static/layui/layui.js"></script>
	<script type="text/javascript" src="static/module/common.js"></script>
	<script type="text/javascript" th:inline="javascript">
	    top.window._ids = new Array();
	    layui.use(['treeSelect','form','layer','jquery','table','laydate','upload','element'],function(){
		    var form = layui.form,
		        layer = layui.layer,
		        laypage = layui.laypage,
		        $ = layui.jquery,
		        table=layui.table,
		        upload = layui.upload,
		        laydate =layui.laydate,
		        //selectY = layui.selectY,
		        element = layui.element,
		        treeSelect= layui.treeSelect;
		    
		    /* treeSelect.render({
	            // 选择器
	            elem: '#departmentName',
	            // 数据
	            data: '/user/deptList',
	            // 异步加载方式：get/post，默认get
	            type: 'get',
	            // 占位符
	            placeholder: '修改默认提示信息',
	            // 是否开启搜索功能：true/false，默认false
	            search: true,
	            // 点击回调
	            click: function(d){
	                $("#departmentId").val(d.current.id);
	            },
	            // 加载完成后的回调函数
	            success: function (d) {
	            	treeSelect.checkNode('departmentName', [[${user.departmentId}]]);
	            }
	        }); */
			
			treeSelect.render({
	            // 选择器
	            elem: '#roleName',
	            // 数据
	            data: '/user/roleList',
	            // 异步加载方式：get/post，默认get
	            type: 'get',
	            // 占位符
	            placeholder: '修改默认提示信息',
	            // 是否开启搜索功能：true/false，默认false
	            search: true,
	            // 点击回调
	            click: function(d){
	            	$("#roleId").val(d.current.id);
	            	if(d.current.name == '供应商'){
	            		$("#vendorDiv").removeClass("layui-hide");
	            	}else{
	            		$("#vendorDiv").addClass("layui-hide");
	            	}
	            },
	            // 加载完成后的回调函数
	            success: function (d) {
//	                选中节点，根据id筛选
	                treeSelect.checkNode('roleName', [[${user.roleId}]]);
	                console.log([[${user.erpSupplier}]]);
	                if([[${user.erpSupplier}]] != null){
	                	$("#vendorDiv").removeClass("layui-hide");
	            	}else{
	            		$("#vendorDiv").addClass("layui-hide");
	            	}

//	                获取zTree对象，可以调用zTree方法
//	                var treeObj = treeSelect.zTree('tree');
//	                console.log(treeObj);

//	                刷新树结构
//	                treeSelect.refresh();
	            }
	        });
		})
	</script>
</body>
</html>